package com.service;

import com.dao.mapper.StudentMapper;
import com.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional( propagation = Propagation.REQUIRED , rollbackFor = Exception.class)
public class StudentServiceImpl implements  StudentService{

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student selectById(int id) {
        return studentMapper.selectById(id);
    }

    @Override
    public List<Student> findByStudent(Student student) {
        return studentMapper.findByStudent(student);
    }

    @Override
    public int insertOne(Student student) {

//        studentMapper.insertOne(student);
        studentMapper.insertOne(student);
//                int i = 1/0;
        studentMapper.insertOne(student);
        return studentMapper.insertOne(student);
    }

    @Override
    public int insertForList(List<Student> list) {
        return studentMapper.insertForList(list);
    }

    @Override
    public int deleteOne(int id) {
        return studentMapper.deleteOne(id);
    }

    @Override
    public int deleteForList(List list) {
        return studentMapper.deleteForList(list);
    }

    @Override
    public int updateOne(Student student) {
        return 0;
    }

    @Override
    public int updateForList(List<Student> list) {
        return 0;
    }
}
